package actions;

import game.constants.ReferenceAction;
import game.constants.ReferenceSpecialFeature;
import interfaces.ActionInterface;
import interfaces.impl.Action;
import objects.SpetialFeature;
import universe.Universe;


public class ActionGiveMinerals extends Action{

	double quantity=0;
	
	@Override
	public ActionInterface cloneAction() {
		ActionGiveMinerals action = new ActionGiveMinerals();
		action.modifyAction(this);
		return action;
	}

	@Override
	public boolean processActionChild(Universe universe) {
		
		SpetialFeature mineralsQuantity= target.getFeature(ReferenceSpecialFeature.SPETIAL_FEATURE_MINERAL_QUANTITY);
		if(mineralsQuantity==null){return false;}
		
		mineralsQuantity.setValue(mineralsQuantity.getValue()-quantity);
	
		return true;
	}

	@Override
	public void initializeName() {
		name="Action Give Minerals";
		
	}

	@Override
	public void initializeId() {
		id=ReferenceAction.ACTION_GIVE_MINERALS;
		
	}

	@Override
	public void modifyChild(ActionInterface action) {
		if (action instanceof ActionGiveMinerals){
			quantity=((ActionGiveMinerals) action).quantity;
		}
		
	}

	public double getQuantity() {
		return quantity;
	}

	public void setQuantity(double quantity) {
		this.quantity = quantity;
	}
	
	

}
